﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HWR_Ants.Classes.Obsolete
{
    [Obsolete]
    class Permutation
    {
        ulong countPermutations;
        string[] perms;
        string[] seperatedPerms;
        public string[] Perms
        {
            get { return perms; }
            set { perms = value; }
        }

        public string[] SeperatedPerms
        {
            get { return seperatedPerms; }
            set { seperatedPerms = value; }
        }

        public ulong CountPermutations
        {
            get { return countPermutations; }
            set { countPermutations = value; }
        }

        public Permutation(int numberOfElements)
        {
            countPermutations = StringPermLib.StringPerm.FactorialLookup(numberOfElements);

            String[] ls = new String[numberOfElements];
            int[] array = new int[numberOfElements];
            perms = new string[countPermutations];

            for (int i = 0; i < numberOfElements; i++)
            {
                array[i] = i;
                ls[i] = i.ToString();
            }

            StringPermLib.StringPerm p = new StringPermLib.StringPerm(ls);
            int counter = 0;
            while (p != null)
            {
                perms[counter] = p.ToString();
                counter++;
                p = p.Successor();
            }

        }

        public Permutation(int numberOfElements, string[] ls)
        {
            countPermutations = StringPermLib.StringPerm.FactorialLookup(numberOfElements);

            int[] array = new int[numberOfElements];
            perms = new string[countPermutations];

            for (int i = 0; i < numberOfElements; i++)
            {
                array[i] = i;
            }

            StringPermLib.StringPerm p = new StringPermLib.StringPerm(ls);
            int counter = 0;
            while (p != null)
            {
                perms[counter] = p.ToString();
                counter++;
                p = p.Successor();
            }

            seperatedPerms = new string[perms.Length];
            counter = 0;

            foreach (string element in perms)
            {
                string[] sep = new string[] { " " };
                string[] temp = element.Split(sep, StringSplitOptions.None);

                foreach (string e in temp)
                {
                    if (e != "{" && e != "}")
                        seperatedPerms[counter] += e + " ";
                }
                counter++;
            }


        }
    }
}
